package com.cosina.game.crystallight.ui.battle.drawable;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Point;

import com.cosina.game.crystallight.engine.AbilityManager;
import com.cosina.game.crystallight.engine.BattleEngine;
import com.cosina.game.crystallight.model.battle.Ability;
import com.cosina.game.crystallight.ui.battle.BattleResource;
import com.cosina.game.crystallight.ui.battle.drawadapter.BaseDrawable;
import com.cosina.game.crystallight.ui.common.PaintSuite;

public class MenuDrawable extends BaseDrawable{

	private Point[] menuPxLocations = new Point[3];
	private Point speedPxLocation = new Point();
	
	public MenuDrawable(){
		Point[] locations = BattleEngine.field.locationAbilities();
		for (int i = 0; i < 3; i++) {
			Point location = locations[i];
			menuPxLocations[i] = new Point(44 * location.x + 5,44 * location.y + 5);
		}
		
		Point accerlation = BattleEngine.field.locationSpeed();
		speedPxLocation.set(44 * accerlation.x + 5, 44 * accerlation.y + 5);
	}
	
	@Override
	public void draw(Canvas canvas) {
		Ability[] abilities = BattleEngine.abilityManager.getContextAbilities();
		for (int i = 0; i < 3; i++) {
			Bitmap bitmap = BattleResource.get(abilities[i].getFrameId());
			canvas.drawBitmap(bitmap,
					menuPxLocations[i].x,menuPxLocations[i].y,
					PaintSuite.p4Simple);
		}
		
		canvas.drawBitmap(BattleResource.get(AbilityManager.gameSpeed.getFrameId()),
				speedPxLocation.x,speedPxLocation.y,
				PaintSuite.p4Simple);
	}
}
